
var api = require('../../utils/api.js');
var app = getApp();
var WxParse = require('../../wxParse/wxParse.js');
Page({
    data: {
        tophe:0,
        htmlSnip:` `
    },
    currentPageNumber: 1,
        onLoad() {
        var file=api.FIlE;
        this.setData({
            bg:file
        })
       
    },
    onShow() {
        let jn = wx.getMenuButtonBoundingClientRect();

        console.log(jn);
        var tophe=jn.top+jn.height+25;
        this.setData({
            tophe:tophe+'px',
            over:jn.top
        })
        this.getmeeting();
     
    },
    back(){
        wx.navigateBack()
    },

    getmeeting(){
        var that=this;
        api.post({
            url: 'index/getaddress',
            data: {id:1},
            success: data => {
                var info=data.data;

                that.setData({
                    htmlSnip:that.formatRichText(data.data.content)
                })
                WxParse.wxParse('articleContent', 'html', data.data.content, this, 30);
               
            },
        });
    },
    formatRichText(html) {
        //控制小程序中图片大小
        let newContent = html.replace(/<img[^>]*>/gi, function(match, capture) {
            console.log(match.search(/style=/gi));
            if (match.search(/style=/gi) == -1) {
                match = match.replace(/\<img/gi, '<img style=""');
            }
            return match;
        });

        newContent = newContent.replace(/style="/gi, '$& max-width:100% !important; ');
        newContent = newContent.replace(/<br[^>]*\/>/gi, '');
        return newContent;
    },



});
